<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/11/3
  Time: 23:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/mb/jsp/common.jsp" %>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登&nbsp;陆</title>
    <!-- 引用jquery.cookie.js -->
    <script src="mb/js/jquery.cookie.js"></script>
</head>
<body  ontouchstart=""  class="w100 h100 of">

<div class="container db h100 h100 of pr starImgBack">
    
    <section class="w100" style="margin-top:23%;">
		<h1 class="cf ffa tc w100" style="font-size:28px;">七彩云购</h1>
		<img src="mb/images/starImg.png" class="db jz hauto" style="width:84%;margin-top:11%;">
	</section>
	
	 <section class="loginBlock w100 db">
	 		<div class="df cf jz mgt10 of">
	 			<img src="mb/images/login-tel.png" class="db hauto">
	 			<p class="f15 mgl10">手机号</p>
	 			<div class="mgl10 flexBox" style="flex-grow:2;">
	 				<input type="tel" name="tel" value="" placeholder="请输入手机号" required="required" id="loginTel"/>
	 				<a href="javascript:clearVal($('#loginTel'));"><img src="mb/images/login-clear.png"></a>
	 			</div>
	 		</div>
	 		<div class="df cf jz mgt10 of">
	 			<img src="mb/images/login-pwd.png" class="db hauto">
	 			<p class="f15 mgl10">密  &nbsp;&nbsp;码</p>
	 			<div class="mgl10 flexBox" style="flex-grow:2;">
	 				<input type="password" name="pwd" value="" placeholder="请输入密码" required="required" id="password"/>
	 				<a href="javascript:showPwd($('#password'));"><img src="mb/images/login-eye.png"></a>
	 			</div>
	 		</div>
	 		<div class="clearfix of jz mgt10">
	 			<a href="mb/jsp/forgotPassward.jsp" class="cf f14 dib fr">忘记密码</a>
	 		</div>
            <div class="jz">
                <button type="button" id="loginBub" class="f17 cf tc w100 btnOrange br2">登&nbsp;陆</button>
            </div>
    </section>
    <section class="w100 pf flexCenter" style="bottom:3.5%;left:0">
    	<a href="mb/jsp/fastRegist.jsp" class="cf f14 jz dib" style="border-bottom:1px solid #fff;">快速注册</a>
    </section>
    
</div>

<script>
	function clearVal(enput){
		enput.val("");
	}
	function showPwd(enput){
		if(enput.attr("type")=="password"){
			enput.attr("type","text");
		}else{
			enput.attr("type","password");
		}
	}
    $(function () {
    
	    if ($.cookie("telCookie") != undefined) {
			$("#loginTel").val( $.cookie("telCookie"));//写入cookie记录账号
			} 
		var myTel=$.cookie("telCookie");
    
        $('#loginBub').click(function () {
            var tel =$.trim($('#loginTel').val());
            var password = $.trim($('#password').val());
            var pattern = /^1[0-9]{10}$/;
            
            
            if(tel== ""){
                showToast("你还未填写手机号");
                return false;
            }
            if (!pattern.test(tel)) {
                showToast("请输入正确的手机号码!");
                isPhone = 0;
                return false;
            }
            if(password == ""){
                showToast("请输入密码!");
                return false;
            }
            
              if(tel!="" && myTel != tel){
            	myTel=tel;
            	$.cookie("telCookie", myTel, { expires: 10 , path: '/' }); // 存储一个带10天期限的 cookie,验证记住帐号
            }

            $.ajax({
                url: "LoginServlet",
                data: JSON.stringify({m: 60, mobile: tel, password: $.md5(password), platform: 0}),
                type: 'post',
                dataType: 'json',
                beforeSend: function () {
                    showProgressDg();
                },
                success: function (data) {
                    if (data.state == 1) {
                        // 登录成功 跳转到主页
                        // window.location.href='mb/index.jsp';
                        history.back();
                        // 存储需要刷新首页面
                        localStorage.setItem("needrefreshindex", 'true');
                    } else {
                        showToast(data.info);
                    }
                },
                error: function (data) {
                    showToast(data.info);
                },
                complete: function () {
                    closeProgressDg();
                }
            });
            
            
            
        })

    })

</script>

</body>
</html>
